<div class="newsletters index">
	<h2>
	<?php echo __d('newsletter','Newsletters');?></h2>
	<table cellpadding="0" cellspacing="0">
	<tr><td>
	<?php 	
		echo $this->Form->create("NewsletterMessage",array('url'=>array('controller'=>'newsletters','action'=>'send')));		
		echo $this->Form->input('NewsletterMessage.subject',array('label'=>__d('newsletter','Temat wiadomości')));	
		echo '<label>'.__d('newsletter','Treść wiadomości').'</label>';	
		echo $this->Cksource->ckeditor('NewsletterMessage.content',array('config'=>array('height'=>'600')));
	?>
	
	<?php
	echo $this->Form->submit(__d('newsletter','Wyślij wiadomość'),array('style'=>'float: left;'));
	?>
	<div class='clear'>&nbsp;</div>
	<?php 
		echo $this->Form->checkbox('szablon');
		echo __d('newsletter','Zapisz jako szablon',true);
		 echo $this->Form->end();?>	
	<?php 			
// 		echo $this->Js->get("#ZapiszSzablon")->event('click',
// 			$this->Js->request(array(
// 					'controller'=>'newsletters',
// 					'action'=>'save_szablon'
// 			), array(
// 					'async' => true,
// 					'method' => 'post',
// 					'dataExpression'=>true,
// 					'data'=> $this->Js->serializeForm(array(
// 						'isForm' => false,
// 						'inline' => true
// 					)),
// 					'complete' => 'window.location.href=window.location.href;'
// 			))

// 		);
	?>
	
	</td>
	<td width="25%" valign="top"> 
		<table cellpadding="0" cellspacing="0">
		<tr>
		<th colspan="2" ><?php echo __d('newsletter','Szablony')?></th>		
		</tr>
			<?php foreach ($newsletterMessages as $key => $newsletter_message){ ?>
			<tr>
				<td><?php echo $newsletter_message['NewsletterMessage']['subject']; ?>&nbsp;</td>
				<td class="actions">
					<?php echo $this->Html->link(__d('newsletter','Wybierz'), array('action' => 'admin','szablon' => $newsletter_message['NewsletterMessage']['id'])); ?>
				</td>
			</tr>
			<?php }; ?>
		</table>
	</td>
	</tr>
	</table>
	<table cellpadding="0" cellspacing="0">
	<tr>
			<th><?php 
			echo $this->Form->create("Newsletter").$this->Form->checkbox("Newsltter.all",array('id'=>"NewsltterAll",'checked'=>$this->Session->read('Newsltter.all'))).$this->Form->end(); 

 
			echo $this->Js->get("#NewsltterAll")->event('change',
				$this->Js->request(array(
						'controller'=>'newsletters',
						'action'=>'check'
				), array(
						'update'=>"#NewsltterAllUpdate",
						'async' => true,
						'method' => 'post',
						'dataExpression'=>true,
						'data'=> $this->Js->serializeForm(array(
							'isForm' => false,
							'inline' => true
						)),
						'complete' => 'window.location.href=window.location.href;'
				))

			);
			

		?> Wszyscy <span id="<?php echo "NewsltterAllUpdate"?>"></span></th>			
			<th><?php echo $this->Paginator->sort('name'); ?></th>
			<th><?php echo $this->Paginator->sort('email'); ?></th>
			<th><?php echo $this->Paginator->sort('created'); ?></th>
			<th class="actions"><?php echo __('Actions'); ?></th>
	</tr>
	<?php foreach ($newsletters as $key => $newsletter): ?>
	<tr>
		<td><?php 
			echo $this->Form->create("Newsletter").$this->Form->checkbox("Newsltter.{$newsletter['Newsletter']['id']}",array('id'=>"Newsltter{$key}id",'class'=>'NewsletterCheckbox','checked'=>$newsletter['Newsletter']['status'])).$this->Form->end(); 

 
			echo $this->Js->get("#Newsltter{$key}id")->event('change',
				$this->Js->request(array(
						'controller'=>'newsletters',
						'action'=>'check'
				), array(
						'update'=>"#Newsltter{$key}Update",
						'async' => true,
						'method' => 'post',
						'dataExpression'=>true,
						'data'=> $this->Js->serializeForm(array(
							'isForm' => false,
							'inline' => true
				))
				))
			);

		?><span id="<?php echo "Newsltter{$key}Update"?>"></span></td>
		<td><?php echo h($newsletter['Newsletter']['name']); ?>&nbsp;</td>
		<td><?php echo h($newsletter['Newsletter']['email']); ?>&nbsp;</td>
		<td><?php echo h($newsletter['Newsletter']['created']); ?>&nbsp;</td>
		<td class="actions">
			<?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $newsletter['Newsletter']['id'])); ?>
			<?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $newsletter['Newsletter']['id']), null, __('Are you sure you want to delete # %s?', $newsletter['Newsletter']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
	));
	?>	</p>
	<div class="paging">
	<?php
		echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
		echo $this->Paginator->numbers(array('separator' => ''));
		echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
	?>
	</div>
</div>
<?php echo $this->element('/menu/left')?>

